package bma.common.netty.protobuf.core.impl;

import java.io.IOException;
import java.io.OutputStream;

import bma.common.netty.protobuf.core.PObject;

import com.google.protobuf.GeneratedMessage;

public class PObjectMultipleMessage implements PObject {

	private GeneratedMessage[] messages;

	public static PObjectMultipleMessage create(GeneratedMessage... msgs) {
		PObjectMultipleMessage r = new PObjectMultipleMessage();
		r.messages = msgs;
		return r;
	}

	@Override
	public void writeTo(OutputStream out) throws IOException {
		if (messages != null) {
			for (int i = 0; i < messages.length; i++) {
				messages[i].writeDelimitedTo(out);
			}
		}
	}
}
